﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;

namespace SecurityAgent
{
    [ServiceContract]
    public interface IRoleProviderService
    {
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        bool IsAuthorizedAdmin(string applicationKey, string userToken);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        void AddUsersToRoles(string applicationKey, string operatorToken, string[] usernames, string[] roleNames);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        void CreateRole(string applicationKey, string operatorToken, string roleName);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        void DeleteRole(string applicationKey,  string operatorToken, string roleName, bool throwOnPopulatedRole);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        String[] FindUsersInRole(string applicationKey,  string operatorToken, string roleName, string usernameToMatch);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        RoleCollection GetAllRoles(string applicationKey, string operatorToken);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        RoleCollection GetRolesForUser(string applicationKey, string userToken, string username);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        string[] GetUsersInRole(string applicationKey, string userToken, string roleName);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        bool IsUserInRole(string applicationKey, string userToken, string username, string roleName);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        void RemoveUsersFromRoles(string applicationKey,  string operatorToken, string[] usernames, string[] roleNames);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
        bool RoleExists(string applicationKey,  string operatorToken, string roleName);
       
    }
}
